home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-06-23 | 4.8 KB | 108 lines | [TEXT/MMCC] |
- 6/23/94
-
- CHANGES AND NEW FEATURES IN GRAPHIC ELEMENTS VERSION 1.5
-
- 1. NewGEWorld now takes a GrafPtr instead of a CWindowPtr as a parameter. This change
- change was made for increased generality, and should not affect the operation of
- your code in any way.
-
- 2. A new facility has been added to allow elements to clean up after themselves when
- they are disposed. This is for use by Graphic elements which allocate memory
- on the heap during initialization, and assign pointers to that memory to their
- drawData and/or changeData fields. Such an element may now provide a CleanupProc
- to free up this memory when it is freed.
-
- This facility includes the following:
-
- A function prototype,
-
- typedef pascal void (*CleanupProc)(GEWorldPtr world, GrafElPtr element);
-
- An added field in the basic Graphic Element structure,
-
- element->cleanupProc;
-
- And a function for setting this field,
-
- void SetCleanupProc(GEWorldPtr world, OSType elementID, CleanupProc elemCleanup);
-
- 3. GEWorlds are now scalable at creation. This means that the same graphics and the
- same functions for initializing, moving, and otherwise acting upon Graphic Elements
- can be used in differently-size windows or other grafports with very few changes
- in existing code.
-
- A parameter "scale" has been added to NewGEWorld():
-
- GEWorldPtr NewGEWorld(GrafPtr worldPort, Rect *worldRect,
- Fixed scale, CTabHandle worldColors);
-
- Scale is a standard fixed-point number in which the high-order word represents an
- integer and the low-order word represents a fraction. Scaling is done with reference
- to worldRect, which should be a rectangle the "normal" one-to-one size of this
- GEWorld. The constant scaleOneToOne is provided for the usual case of creating a
- world the same size as worldRect.
-
- In general, individual Graphic Elements, their positions, and their actions are
- automatically scaled to the world they are in. However, sometimes during the creation
- of a scene, it is necessary to position a newly-created element in relation to one
- which already exists. For example, in one of the example programs, the bottom right
- corner of the cannon's smoke is 16 pixels right and 16 pixels down from the top left
- corner of the cannon, when both are drawn at full size.
-
- When the smoke is created, the cannon's position has already been scaled to its
- world, so we must position the smoke in relation to the cannon's *actual*
- coordinates within the world. However, the 16-pixel offset will be wrong for
- worlds which are smaller or larger than the "actual size" of the graphics.
-
- The following changes have been made in Graphic Elements to handle this situation:
-
- The PtrMoveTo() function now has an additional Boolean parameter, doScale:
-
- void PtrMoveElementTo(GEWorldPtr world, GrafElPtr element,
- short h, short v, Boolean doScale);
-
- If doScale is true, h and v are scaled to the coordinate system of world before
- the move. Otherwise, they are accepted as absolute pixel coordinates within the
- world.
-
- To handle cases such as the smoke's 16-pixel offset from the top left of the cannon,
- Graphic Elements provides the function:
-
- short ScaleToWorld(GEWorldPtr world, short value);
-
- This function returns value scaled to the coordinate system of world.
-
- 4) RectHeight(Rect *r) and RectWidth(Rect *r) have been added to the services provided
- by the Rects module.
-
- 5) Collision handling has been enhanced. For most Graphic Elements, the fact that they
- have collided with another elements is enough: they explode, bounce, or perform some
- other single action in response to the collision.
-
- Others, however, may need to perform an action repeatedly for as long as the collision
- state continues, or perform one action when the collision state begins and another
- when it ends. Graphic Elements now makes the following provisions for these cases:
-
- An enumerated type has been added:
-
- typedef enum {collisionBegin, collisionContinue, collisionEnd} CollisionPhase;
-
- The prototype of a CollisionProc has been updated to include a parameter of this type:
-
- typedef pascal void (*CollisionProc)(GEWorldPtr world, GrafElPtr element,
- GEDirection dir, CollisionPhase phase, GrafElPtr hitElement);
-
- An element's collision function will be called once when the collision first occurs,
- repeatedly for as long as it remains in a collision state with another element, and once
- when the collision condition ends.
-
- 6) A very general special-effects module has been added. This module is provided in
- linkable-library form in GELib:GEExtras.lib (or GEExtrasCW.lib). Example special
- effects are included in Extras:SFXProcs.c. Complete documentation for this module
- will be available at a later date. For now, see the header files and examples in
- GEDemo and GETest, along with the sample effects in SFXProcs.c.
-
-
-
-
-